﻿// ....................................................................................................................
//	Author: Copyright (C) 2012 Ing. Marek Hubal
//	Email: hubal@acasoftware.org
// ....................................................................................................................

using System;

namespace core
{
    /// <summary>Trieda IFileExplorerForm_EditNodeFilter</summary>
    public class IFileExplorerForm_EditNodeFilter : IForm
    {
        public INodeFilter Value; // Hodnota pre editaciu

        protected IGroupBox FGrp; // Controls
        protected IButton FBtn_OK;
        protected IButton FBtn_Cancel;
        protected IButton FBtn_Clear;

        protected IGroupBox FGrp_Name; // Nazov
        protected ICheckBox FCheck_UseName;
        protected ITextBox FTextBox_Name;

        protected IGroupBox FGrp_Attributes; // Atributy
        protected ICheckBox FCheck_UseAttributes;
        protected ILabel[] FLabel_Attrs;
        protected IComboBox_ThreeState[] FCombo_Attrs;

        protected IGroupBox FGrp_Size; // Velkost
        protected ICheckBox FCheck_UseSize;
        protected IComboBox FCombo_Size1;
        protected ITextBox FTextBox_Size;
        protected IComboBox FCombo_Size2;

        protected IGroupBox FGrp_Age; // Vek
        protected ICheckBox FCheck_UseAge;
        protected ILabel FLabel_Age;
        protected ITextBox FTextBox_Age;
        protected IComboBox FCombo_Age;

        protected IGroupBox FGrp_DCreate; // Datum vytvorenia
        protected ICheckBox FCheck_UseDCreate;
        protected IDateTimePicker FDTP_DCreateMin, FDTP_DCreateMax;

        protected IGroupBox FGrp_DModify; // Datum modifikacie
        protected ICheckBox FCheck_UseDModify;
        protected IDateTimePicker FDTP_DModifyMin, FDTP_DModifyMax;

        protected IGroupBox FGrp_DLastAccess; // Datum posledneho pristupu
        protected ICheckBox FCheck_UseDLastAccess;
        protected IDateTimePicker FDTP_DLastAccessMin, FDTP_DLastAccessMax;

            /// <summary>Konstruktor</summary>
        public IFileExplorerForm_EditNodeFilter()
        {
            Value = new INodeFilter();
        }
        /// <summary>Dispose metoda</summary>
        /// <param name="disposing">parameter</param>
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing); // Volam predchodcu
            Value = (INodeFilter)ICore.DisposeObject(Value); // Zrusim objekt
        }

        /// <summary>Metoda: OnCreateForm</summary>
        /// <returns>true / false</returns>
        protected override bool OnCreateForm()
        {
            if (!base.OnCreateForm()) return false; // Volam predchodcu

            // Inicializacia
            MinimizeBox = false; MaximizeBox = false; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; ShowIcon = true; ShowInTaskbar = false; StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

            SetBounds(0, 0, 678, 510); System.Drawing.Size CS = ClientSize;

            // Vytvorim groupbox
            FGrp = new IGroupBox(); IControl.PlaceControl_Inside(FGrp, this, 10, 10, 10, 50);

            // Vytvorim tlacidla
            FBtn_Clear = new IButton(lang.FORM_EDIT_FILTER_TEXT_1, Event_BtnClearClick); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FBtn_Clear, FGrp, 0, 10);
            FBtn_Cancel = new IButton(lang.FORM_EDIT_FILTER_TEXT_3); IControl.PlaceControl_Outside_TopRight_RightBottom(FBtn_Cancel, FGrp, 0, 10); FBtn_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            FBtn_OK = new IButton(lang.FORM_EDIT_FILTER_TEXT_2, Event_BtnOKClick); IControl.PlaceControl_Outside_TopRight_LeftTop(FBtn_OK, FBtn_Cancel, 0, 10);

            // Nazov polozky
            FGrp_Name = new IGroupBox(); IControl.PlaceControl_Inside_LeftTop_LeftTop(FGrp_Name, FGrp, 10, 10, 250, 80);
            FCheck_UseName = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_4); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseName, FGrp_Name, 10, 14);
            FTextBox_Name = new ITextBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FTextBox_Name, FCheck_UseName, 0, 0, 220, -1);
            FGrp_Name.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseName, FTextBox_Name });
            IControl.SetAutoHeight(FGrp_Name, FTextBox_Name, 14);

            // Atributy
            FGrp_Attributes = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp_Attributes, FGrp_Name, 0, 4, 250, 340);
            FCheck_UseAttributes = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_5); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseAttributes, FGrp_Attributes, 10, 14);
            FLabel_Attrs = new ILabel[7]; FCombo_Attrs = new IComboBox_ThreeState[7];

            FLabel_Attrs[0] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_1_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[0], FCheck_UseAttributes, 10, 0);
            FCombo_Attrs[0] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_1_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[0], FLabel_Attrs[0], 2, -7, 200);
            FLabel_Attrs[1] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_2_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[1], FCombo_Attrs[0], -2, 2);
            FCombo_Attrs[1] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_2_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[1], FLabel_Attrs[1], 2, -7, 200);
            FLabel_Attrs[2] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_3_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[2], FCombo_Attrs[1], -2, 2);
            FCombo_Attrs[2] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_3_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[2], FLabel_Attrs[2], 2, -7, 200);
            FLabel_Attrs[3] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_4_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[3], FCombo_Attrs[2], -2, 2);
            FCombo_Attrs[3] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_4_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[3], FLabel_Attrs[3], 2, -7, 200);
            FLabel_Attrs[4] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_5_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[4], FCombo_Attrs[3], -2, 2);
            FCombo_Attrs[4] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_5_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[4], FLabel_Attrs[4], 2, -7, 200);
            FLabel_Attrs[5] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_6_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[5], FCombo_Attrs[4], -2, 2);
            FCombo_Attrs[5] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_6_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[5], FLabel_Attrs[5], 2, -7, 200);
            FLabel_Attrs[6] = new ILabel(lang.FORM_EDIT_FILTER_TEXT_5_7_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Attrs[6], FCombo_Attrs[5], -2, 2);
            FCombo_Attrs[6] = new IComboBox_ThreeState(lang.FORM_EDIT_FILTER_TEXT_5_7_2); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Attrs[6], FLabel_Attrs[6], 2, -7, 200);

            FGrp_Attributes.Controls.Add(FCheck_UseAttributes);
            FGrp_Attributes.Controls.AddRange(FLabel_Attrs);
            FGrp_Attributes.Controls.AddRange(FCombo_Attrs);
            IControl.SetAutoHeight(FGrp_Attributes, FCombo_Attrs[6], 14);

            // Velkost
            FGrp_Size = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_TopRight(FGrp_Size, FGrp_Name, 0, 10, 370);
            FCheck_UseSize = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_6); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseSize, FGrp_Size, 10, 14);
            FCombo_Size1 = new IComboBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FCombo_Size1, FCheck_UseSize, 10, 0, 150);
            FTextBox_Size = new ITextBox(); IControl.PlaceControl_Outside_LeftTop_TopRight(FTextBox_Size, FCombo_Size1, 1, 10, 100, -1);
            FCombo_Size2 = new IComboBox(); IControl.PlaceControl_Outside_LeftTop_TopRight(FCombo_Size2, FTextBox_Size, -1, 10, 70);

            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, "="), INodeFilter.COMPARE_MODE_E);
            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, "<>"), INodeFilter.COMPARE_MODE_NE);
            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, "<"), INodeFilter.COMPARE_MODE_L);
            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, "<="), INodeFilter.COMPARE_MODE_LE);
            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, ">"), INodeFilter.COMPARE_MODE_G);
            FCombo_Size1.AddItem(string.Format(lang.FORM_EDIT_FILTER_TEXT_6_1, ">="), INodeFilter.COMPARE_MODE_GE);
            FCombo_Size2.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_6_2, 0, '\b'), INodeFilter.SIZE_MODE_B);
            FCombo_Size2.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_6_2, 1, '\b'), INodeFilter.SIZE_MODE_KB);
            FCombo_Size2.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_6_2, 2, '\b'), INodeFilter.SIZE_MODE_MB);
            FCombo_Size2.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_6_2, 3, '\b'), INodeFilter.SIZE_MODE_GB);
            
            FGrp_Size.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseSize, FCombo_Size1, FTextBox_Size, FCombo_Size2 });
            IControl.SetAutoHeight(FGrp_Size, FCombo_Size2, 14);

            // Vek objektu
            FGrp_Age = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp_Age, FGrp_Size, 0, 4, 370);
            FCheck_UseAge = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_7); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseAge, FGrp_Age, 10, 14);
            FLabel_Age = new ILabel(lang.FORM_EDIT_FILTER_TEXT_7_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FLabel_Age, FCheck_UseAge, 10, 0);
            FTextBox_Age = new ITextBox(); 
            FCombo_Age = new IComboBox(); 

            FGrp_Age.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseAge, FLabel_Age, FTextBox_Age, FCombo_Age });
            IControl.PlaceControl_Outside_LeftTop_TopRight(FTextBox_Age, FLabel_Age, -1, 10, 80);
            IControl.PlaceControl_Outside_LeftTop_TopRight(FCombo_Age, FTextBox_Age, -1, 10, 80);

            FCombo_Age.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_7_2, 0, '\b'), INodeFilter.AGE_MODE_MINUTE);
            FCombo_Age.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_7_2, 1, '\b'), INodeFilter.AGE_MODE_HOUR);
            FCombo_Age.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_7_2, 2, '\b'), INodeFilter.AGE_MODE_DAY);
            FCombo_Age.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_7_2, 3, '\b'), INodeFilter.AGE_MODE_MONTH);
            FCombo_Age.AddItem(ICore.GetSubstring(lang.FORM_EDIT_FILTER_TEXT_7_2, 4, '\b'), INodeFilter.AGE_MODE_YEAR);

            FGrp_Age.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseAge, FLabel_Age, FTextBox_Age, FCombo_Age });
            IControl.SetAutoHeight(FGrp_Age, FCombo_Age, 14);

            // Datum vytvorenia
            FGrp_DCreate = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp_DCreate, FGrp_Age, 0, 4, 370);
            FCheck_UseDCreate = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_8); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseDCreate, FGrp_DCreate, 10, 14);
            FDTP_DCreateMin = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DCreateMin, FCheck_UseDCreate, 0, 0, 170);
            FDTP_DCreateMax = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_2); IControl.PlaceControl_Outside_LeftTop_TopRight(FDTP_DCreateMax, FDTP_DCreateMin, 0, 10, 170);
            FGrp_DCreate.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseDCreate, FDTP_DCreateMin, FDTP_DCreateMax });
            IControl.SetAutoHeight(FGrp_DCreate, FDTP_DCreateMax, 14);

            // Datum modifikacie
            FGrp_DModify = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp_DModify, FGrp_DCreate, 0, 4, 370);
            FCheck_UseDModify = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_9); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseDModify, FGrp_DModify, 10, 14);
            FDTP_DModifyMin = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DModifyMin, FCheck_UseDModify, 0, 0, 170);
            FDTP_DModifyMax = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_2); IControl.PlaceControl_Outside_LeftTop_TopRight(FDTP_DModifyMax, FDTP_DModifyMin, 0, 10, 170);
            FGrp_DModify.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseDModify, FDTP_DModifyMin, FDTP_DModifyMax });
            IControl.SetAutoHeight(FGrp_DModify, FDTP_DModifyMax, 14);

            // Datum posledneho pristupu
            FGrp_DLastAccess = new IGroupBox(); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FGrp_DLastAccess, FGrp_DModify, 0, 4, 370);
            FCheck_UseDLastAccess = new ICheckBox(lang.FORM_EDIT_FILTER_TEXT_10); IControl.PlaceControl_Inside_LeftTop_LeftTop(FCheck_UseDLastAccess, FGrp_DLastAccess, 10, 14);
            FDTP_DLastAccessMin = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_1); IControl.PlaceControl_Outside_LeftTop_LeftBottom(FDTP_DLastAccessMin, FCheck_UseDLastAccess, 0, 0, 170);
            FDTP_DLastAccessMax = new IDateTimePicker(true, lang.FORM_EDIT_FILTER_TEXT_8_2); IControl.PlaceControl_Outside_LeftTop_TopRight(FDTP_DLastAccessMax, FDTP_DLastAccessMin, 0, 10, 170);
            FGrp_DLastAccess.Controls.AddRange(new System.Windows.Forms.Control[] { FCheck_UseDLastAccess, FDTP_DLastAccessMin, FDTP_DLastAccessMax });
            IControl.SetAutoHeight(FGrp_DLastAccess, FDTP_DLastAccessMax, 14);

            FGrp.Controls.AddRange(new System.Windows.Forms.Control[] { FGrp_Name, FGrp_Attributes, FGrp_Size, FGrp_Age, FGrp_DCreate, FGrp_DModify, FGrp_DLastAccess });
            Controls.AddRange(new System.Windows.Forms.Control[] { FGrp, FBtn_OK, FBtn_Cancel, FBtn_Clear }); // Zaradim do controls


            FCheck_UseName.CheckedChanged += Event_CheckedChanged;
            FCheck_UseAttributes.CheckedChanged += Event_CheckedChanged;
            FCheck_UseSize.CheckedChanged += Event_CheckedChanged;
            FCheck_UseAge.CheckedChanged += Event_CheckedChanged;
            FCheck_UseDCreate.CheckedChanged += Event_CheckedChanged;
            FCheck_UseDModify.CheckedChanged += Event_CheckedChanged;
            FCheck_UseDLastAccess.CheckedChanged += Event_CheckedChanged;

            AcceptButton = FBtn_OK; CancelButton = FBtn_Cancel; FBtn_OK.Focus();

            FillForm(Value); // Vyplnim zaciatocnou hodnotou
            return true; // Vsetko OK
        }

        /// <summary>Vyplnenie formulara</summary>
        /// <param name="pValue">objekt</param>
        protected void FillForm(INodeFilter pValue)
        {
            FCheck_UseName.Checked = pValue.UseName; // Nastavim nazov
            FCheck_UseAttributes.Checked = pValue.UseAttributes;
            FCheck_UseAge.Checked = pValue.UseAge;
            FCheck_UseSize.Checked = pValue.UseSize;
            FCheck_UseDCreate.Checked = pValue.UseDCreate;
            FCheck_UseDModify.Checked = pValue.UseDModify;
            FCheck_UseDLastAccess.Checked = pValue.UseDLastAccess;

            FTextBox_Name.Text = pValue.UseName ? pValue.FilterValue_Name : "";
            FCombo_Attrs[0].Value = pValue.FilterValue_Attr_Directory;
            FCombo_Attrs[1].Value = pValue.FilterValue_Attr_Archive;
            FCombo_Attrs[2].Value = pValue.FilterValue_Attr_Compressed;
            FCombo_Attrs[3].Value = pValue.FilterValue_Attr_Encrypted;
            FCombo_Attrs[4].Value = pValue.FilterValue_Attr_Hidden;
            FCombo_Attrs[5].Value = pValue.FilterValue_Attr_Readonly;
            FCombo_Attrs[6].Value = pValue.FilterValue_Attr_System;
            FCombo_Age.SelectedIntID = pValue.FilterValue_AgeMode;
            FTextBox_Age.Text = pValue.UseAge ? pValue.FilterValue_Age.ToString() : "";
            FCombo_Size1.SelectedIntID = pValue.FilterValue_SizeCompareMode;
            FCombo_Size2.SelectedIntID = pValue.FilterValue_SizeMode;
            FTextBox_Size.Text = pValue.UseSize ? pValue.FilterValue_Size.ToString() : "";
            FDTP_DCreateMin.Value = pValue.UseDCreate ? pValue.FilterValue_DCreateMin : DateTime.MinValue;
            FDTP_DCreateMax.Value = pValue.UseDCreate ? pValue.FilterValue_DCreateMax : DateTime.MinValue;
            FDTP_DModifyMin.Value = pValue.UseDModify ? pValue.FilterValue_DModifyMin : DateTime.MinValue;
            FDTP_DModifyMax.Value = pValue.UseDModify ? pValue.FilterValue_DModifyMax : DateTime.MinValue;
            FDTP_DLastAccessMin.Value = pValue.UseDLastAccess ? pValue.FilterValue_DLastAccessMin : DateTime.MinValue;
            FDTP_DLastAccessMax.Value = pValue.UseDLastAccess ? pValue.FilterValue_DLastAccessMax : DateTime.MinValue;

            UpdateStates(); // Aktualizujem stavy
        }
        /// <summary>Aktualizacia stavov controls</summary>
        protected void UpdateStates()
        {
            FTextBox_Name.Enabled = FCheck_UseName.Checked;
            FCombo_Size1.Enabled = FCheck_UseSize.Checked;
            FCombo_Size2.Enabled = FCheck_UseSize.Checked;
            FTextBox_Size.Enabled = FCheck_UseSize.Checked;
            FCombo_Age.Enabled = FCheck_UseAge.Checked;
            FTextBox_Age.Enabled = FCheck_UseAge.Checked;
            for (int i = 0; i < FCombo_Attrs.Length; i++) FCombo_Attrs[i].Enabled = FCheck_UseAttributes.Checked;
            FDTP_DCreateMin.Enabled = FDTP_DCreateMax.Enabled = FCheck_UseDCreate.Checked;
            FDTP_DModifyMin.Enabled = FDTP_DModifyMax.Enabled = FCheck_UseDModify.Checked;
            FDTP_DLastAccessMin.Enabled = FDTP_DLastAccessMax.Enabled = FCheck_UseDLastAccess.Checked;
        }
        /// <summary>Otestovanie validity formulara</summary>
        /// <returns>true / false</returns>
        protected bool CheckForm()
        {
            bool UseSomething = false; // Priznak ci sa nieco pouziva
            if (FCheck_UseName.Checked) // Ma sa pouzit nazov?
            {
                if (FTextBox_Name.Text.Trim() == "") // Nezadane meno?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_2);
                    FTextBox_Name.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseSize.Checked) // Ma sa pouzit velkost?
            {
                if (!FTextBox_Size.IsValidLong(0)) // Nie je platna velkost?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_3);
                    FTextBox_Size.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseAge.Checked) // Ma sa pouzit vek?
            {
                if (!FTextBox_Age.IsValidInt(0)) // Nie je platny vek?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_4);
                    FTextBox_Age.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseAttributes.Checked) // Maju sa pouzit atributy?
            {
                bool B = FCombo_Attrs[0].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[1].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[2].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[3].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[4].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[5].Value != ICore.TS_NONE;
                B |= FCombo_Attrs[6].Value != ICore.TS_NONE;

                if (!B) // Ziaden atribut do uvahy?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_5);
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseDCreate.Checked) // Ma sa pouzit datum vytvorenia?
            {
                if ((FDTP_DCreateMin.Value == DateTime.MinValue) && (FDTP_DCreateMax.Value == DateTime.MinValue)) // Nie je aspon jeden nastaveny?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_6);
                    FDTP_DCreateMin.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseDModify.Checked) // Ma sa pouzit datum modifikacie?
            {
                if ((FDTP_DModifyMin.Value == DateTime.MinValue) && (FDTP_DModifyMax.Value == DateTime.MinValue)) // Nie je aspon jeden nastaveny?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_7);
                    FDTP_DModifyMin.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (FCheck_UseDLastAccess.Checked) // Ma sa pouzit datum posledneho pristupu?
            {
                if ((FDTP_DLastAccessMin.Value == DateTime.MinValue) && (FDTP_DLastAccessMax.Value == DateTime.MinValue)) // Nie je aspon jeden nastaveny?
                {
                    IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_8);
                    FDTP_DLastAccessMin.Focus();
                    return false;
                }
                UseSomething = true; // Nastavim priznak pouzitia
            }

            if (!UseSomething) // Nic sa nepouziva?
            {
                IApp.ShowError(lang.FORM_EDIT_FILTER_TEXT_11_1);
                return false;
            }
            return true; // Vsetko OK
        }
        /// <summary>Nacitanie obsahu formulara do objektu</summary>
        /// <param name="Result">vysledok</param>
        protected void ReadForm(INodeFilter Result)
        {
            Result.Init(); // Inicializujem

            Result.UseAge = FCheck_UseAge.Checked; // Ulozim pouzitia
            Result.UseAttributes = FCheck_UseAttributes.Checked;
            Result.UseDCreate = FCheck_UseDCreate.Checked;
            Result.UseDLastAccess = FCheck_UseDLastAccess.Checked;
            Result.UseDModify = FCheck_UseDModify.Checked;
            Result.UseName = FCheck_UseName.Checked;
            Result.UseSize = FCheck_UseSize.Checked;

            if (Result.UseAge) // Pouzit vek?
            {
                Result.FilterValue_Age = ICore.ToInt(FTextBox_Age.Text);
                Result.FilterValue_AgeMode = FCombo_Age.SelectedIntID;
            }

            if (Result.UseAttributes) // Pouzit atributy?
            {
                Result.FilterValue_Attr_Archive = (byte)FCombo_Attrs[1].Value;
                Result.FilterValue_Attr_Compressed = (byte)FCombo_Attrs[2].Value;
                Result.FilterValue_Attr_Directory = (byte)FCombo_Attrs[0].Value;
                Result.FilterValue_Attr_Encrypted = (byte)FCombo_Attrs[3].Value;
                Result.FilterValue_Attr_Hidden = (byte)FCombo_Attrs[4].Value;
                Result.FilterValue_Attr_Readonly = (byte)FCombo_Attrs[5].Value;
                Result.FilterValue_Attr_System = (byte)FCombo_Attrs[6].Value;
            }

            if (Result.UseDCreate) // Pouzit datum vytvorenia
            {
                Result.FilterValue_DCreateMin = FDTP_DCreateMin.Value;
                Result.FilterValue_DCreateMax = FDTP_DCreateMax.Value;
            }

            if (Result.UseDModify) // Pouzit datum modifikacie
            {
                Result.FilterValue_DModifyMin = FDTP_DModifyMin.Value;
                Result.FilterValue_DModifyMax = FDTP_DModifyMax.Value;
            }

            if (Result.UseDLastAccess) // Pouzit datum posledneho pristupu
            {
                Result.FilterValue_DLastAccessMin = FDTP_DLastAccessMin.Value;
                Result.FilterValue_DLastAccessMax = FDTP_DLastAccessMax.Value;
            }

            if (Result.UseName)
            {
                Result.FilterValue_Name = FTextBox_Name.Text.Trim();
            }

            if (Result.UseSize)
            {
                Result.FilterValue_Size = ICore.ToLong(FTextBox_Size.Text);
                Result.FilterValue_SizeCompareMode = FCombo_Size1.SelectedIntID;
                Result.FilterValue_SizeMode = FCombo_Size2.SelectedIntID;
            }
        }

        /// <summary>Event: CheckedChanged</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_CheckedChanged(object pSender, EventArgs e)
        {
            UpdateStates(); // Aktualizujem okno
        }
        /// <summary>Event: OnClick pre tlacidlo FBtn_OK</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnOKClick(object pSender, EventArgs e)
        {
            if (!CheckForm()) return; // Test validity
            ReadForm(Value); // Nacitam obsah
            DialogResult = System.Windows.Forms.DialogResult.OK; // Ukoncim dialog
        }
        /// <summary>Event: OnClick pre tlacidlo FBtn_Clear</summary>
        /// <param name="pSender">zdroj</param>
        /// <param name="e">parameter</param>
        protected void Event_BtnClearClick(object pSender, EventArgs e)
        {
            using (INodeFilter F = new INodeFilter())
            {
                FillForm(F);
            }
        }

    }
}
